package jmine.tec.hydra.domain.senderRegistry;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import jmine.tec.hydra.send.Sender;
import jmine.tec.persist.annotation.Alias;
import jmine.tec.persist.annotation.Comment;
import jmine.tec.persist.annotation.Constraint;
import jmine.tec.persist.annotation.UniqueConstraint;
import bancosys.tec.component.Documentation;
import bancosys.tec.persist.bussobj.PersistableBusinessObject;
import bancosys.tec.persist.persister.annotation.NaturalKey;
import bancosys.tec.persist.persister.annotation.SystemId;

/**
 * Registro de destinos de mensagens do Hydra
 * 
 * @author lundberg
 */
@Entity
@Table(name = "HYDRA_SEND_REG")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Alias("HYDSRG")
@Constraint(name = "CK_HYDSRG_0")
@DiscriminatorColumn(name = "DISCR", length = 1, discriminatorType = DiscriminatorType.INTEGER)
@Comment(table = "HYDRA_SEND_REG", column = "DISCR", value = "DISCRIMINADOR DO REGISTRO DE DESTINO DE MENSAGENS.")
@SequenceGenerator(name = "SEQ_HYDSRG", sequenceName = "SEQ_HYDSRG")
@Documentation("ARMAZENA OS REGISTROS DE ENVIO DE MENSAGENS.")
public abstract class AbstractSenderRegistry extends PersistableBusinessObject {

    private Long id;

    private String mnemonico;

    /**
     * @return o id do registro de envio.
     */
    @Id
    @SystemId
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_HYDSRG")
    @Column(name = "COD_HYDRA_SEND_REG", nullable = false)
    @Documentation("CODIGO DO REGISTRO DE ENVIO DE MENSAGEM.")
    public Long getId() {
        return this.id;
    }

    /**
     * @param id o valor do id do registro de envio.
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the mnemonico
     */
    @NaturalKey
    @UniqueConstraint(name = "AK_HYDSRG_0")
    @Column(name = "MNE", nullable = false)
    @Documentation("MNEMONICO DO REGISTRO DE ENVIO DE MENSAGENS")
    public String getMnemonico() {
        return this.mnemonico;
    }

    /**
     * @param mnemonico the mnemonico to set
     */
    public void setMnemonico(String mnemonico) {
        this.mnemonico = mnemonico;
    }

    /**
     * @return o sender que grava o xml resultante em um arquivo no diretorio passado.
     */
    @Transient
    public abstract Sender getSender();
}
